<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@taglib prefix="s" uri="strutsTags"%>
<%@taglib prefix="ty" uri="/wyzzTags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<head>
	<base href="<%=basePath%>">
	<title>每月考勤汇总</title>
	<jsp:include flush="true" page="/sitemesh/jsPackage.jsp"></jsp:include>
	<link href="resource/css/style.css" rel="stylesheet" type="text/css" />
	<script type='text/javascript' src='dwr/interface/DwrForAttend.js'></script>
</head>
<body onload="HRMCommon.check_order();">
	<s:component template="bodyhead">
		<s:param name="pagetitle" value="'每月考勤汇总('+startDate+'到'+endDate+')'" />
	</s:component>

	<s:form id="searchAttendmonthly" name="searchAttendmonthly"
		action="searchAttendmonthly" namespace="/examin" method="POST">
		<s:token />
		<table width="100%" class="formtable">
			<tr>
				<td>
					<s:hidden id="status" name="status" />
					<s:hidden id="delAttendIds" name="delAttendIds" />
					<s:hidden id="order" name="page.order" />
					<s:hidden id="operate" name="page.operate" />
					<s:hidden id="page.currentPage" name="page.currentPage" />
					<table width="100%">
						<tr>
							<s:textfield label="员工" id="empName" name="emp" size="16"
								maxlength="64" />
							<s:select label="用工形式" name="employee.empType.id" list="empType"
								listKey="id" listValue="emptypeName" multiple="false"
								emptyOption="true" value="employee.empType.id" size="1" />
							<s:select id="searchType" label="考勤状态" name="searchType"
								value="searchType"
								list="#{0:'请选择',2:'有迟到',3:'有早退',5:'有旷工',1:'有请假',4:'有加班'}"
								emptyOption="false" />
						</tr>
						<tr>
							<td align="right">
								组织单元:
							</td>
							<td>
								<s:orgselector id="orgselector1"
									name="employee.empDeptNo.departmentName"
									hiddenFieldName="employee.empDeptNo.id" />
							</td>
							<s:select label="工作地区" list="locations" listKey="id"
								name="employee.empLocationNo.id" listValue="locationName"
								multiple="false" emptyOption="true"
								value="employee.empLocationNo.id" size="1" />
							<s:select label="按天/小时" id="searchMode" name="searchMode"
								list="#{0:'按天',1:'按小时'}" onchange="submitSearch();" />
						</tr>
					</table>
				</td>
				<td>
					<input title="[Alt+F]" accesskey="F" name="submit_button"
						class="button" type="button" onclick="submitSearch();" value="查询">
					<input title="[Alt+C]" accesskey="C" name="clear_button"
						class="button" type="button"
						onClick="window.location='searchAttendmonthly.action';" value="重置">
				</td>
			</tr>
		</table>

		<!-- 操作 -->
		<div class="operatediv">
			<span class="operatedivleft"> <s:hidden name="searchOrExport"
					id="searchOrExport" /> <s:hidden id="output-ommId"
					name="outmatchModelId" /> <s:hidden id="output-ioName"
					name="outputIoName" /> <input class="button" type="button"
					id="down" name="down" value="前一月"
					onclick="HRMCommon.changeMonth(-1,'searchAttendmonthly');">
				<s:textfield id="yearMonth" name="yearMonth" size="7" maxlength="7"
					onclick="WdatePicker({dateFmt:'yyyy-MM', el:'yearMonth'})"
					onchange="HRMCommon.checkYMAndSubmit(this,'searchAttendmonthly')" />
				<input class="button" type="button" id="up" name="up" value="后一月"
					onclick="HRMCommon.changeMonth(1,'searchAttendmonthly');">
				<ty:auth auths="401,3">
					<s:if test="period.attpStatus==1">
						<input class="button" type="button" id="closeRecord"
							name="closeAttend" value="审核" onclick="closeAttendperiod();">
					</s:if>
					<s:elseif test="period.attpStatus==2">
						<input class="button" type="button" id="openRecord"
							name="openAttend" value="解封" onclick="reOpenAttendperiod()">
					</s:elseif>
				</ty:auth> <ty:auth auths="401,2 or 401,3">
					<s:if test="period.attpStatus==0">
						<input class="button" type="button" id="approve"
							name="approveAttend" value="封帐申请" onclick="applyAttendperiod()">
						<input class="button" type="button" id="initAttend"
							name="initAttend" value="重新初始化" onclick="initAttdRecords();">
						<input class="button" type="button" id="delAttend"
							name="delAttend" value="数据删除" onclick="batchDelAttend();">
					</s:if>
					<s:if test="period==null || period.attpStatus==0">
						<input class="button" type="button"
							onclick="initDivImmUpload('IExamMonthly','<s:property value="yearMonth" />')"
							value="导入考勤" />
					</s:if>
					<input class="button" id="btnOutput" type="button" value="数据导出"
						onclick="submitExport();" alt="右击选择导出类型" title="右击选择导出类型" />
				</ty:auth> </span>
			<span class="operatedivright">本次查询共得到<s:property
					value="page.totalRows" />条每月考勤记录</span>
		</div>

		<div id="scrollDiv" style="overflow: scroll; width: 600;">
			<jsp:include page="search_attendmonthly_by_dayOrHour.jsp"
				flush="true"></jsp:include>
			<s:pager end="page.end" pageNo="page.currentPage"
				totalRows="page.totalRows" totalPages="page.totalPages"
				formId="searchAttendmonthly" start="page.start" />
		</div>
	</s:form>

	<div id="dlgExaminDetail" style="width: 750px; display: none;">
		<table id="examinDetailTable" width="100%" border="0" cellspacing="0"
			cellpadding="0" class="basictable">
			<thead>
				<tr>
					<th>
						考勤日期
					</th>
					<th>
						班次
					</th>
					<th>
						上班时间
					</th>
					<th>
						下班时间
					</th>
					<th>
						应出勤
					</th>
					<th>
						迟到(分)
					</th>
					<th>
						早退(分)
					</th>
					<th>
						缺勤
					</th>
					<th>
						请假
					</th>
					<th>
						加班(小时)
					</th>
					<th>
						异常信息
					</th>
				</tr>
			</thead>
			<tbody id="memoryDataArea">
			</tbody>
		</table>
	</div>

	<script type="text/javascript" language="javascript">
	/*****************************************************
	 * 每月考勤重新初始化
	 * 返回值： 无
	 *****************************************************/
	function initAttdRecords() {
		var date = HRMCommon.checkY_M(document.getElementById("yearMonth"));
		if (date == null)
			return;

		if (!confirm("确定要初始化" + date + "的月考勤记录么？已有的当月考勤汇总将被删除。")) {
			return false;
		}
		document.searchAttendmonthly.action = "examin/calDailyToAttendmonthly.action";
		document.searchAttendmonthly.submit();
	}

	/***封帐申请，封帐提交，封帐，解封***************/
	//封帐申请
	function applyAttendperiod() {
		var date = HRMCommon.checkY_M(document.getElementById("yearMonth"));
		if (date == null)
			return;

		if (!confirm("您确定申请封帐" + date + "每月考勤汇总吗？"))
			return;
		document.getElementById('status').value = 1;
		document.searchAttendmonthly.action = "examin/applyAttendperiod.action";
		document.searchAttendmonthly.submit();
	}
	//封帐
	function closeAttendperiod() {
		var date = HRMCommon.checkY_M(document.getElementById("yearMonth"));
		if (date == null)
			return;

		if (!confirm("您确定封帐" + date + "每月考勤汇总吗？"))
			return;
		document.getElementById('status').value = 2;
		document.searchAttendmonthly.action = "examin/closeAttendperiod.action";
		document.searchAttendmonthly.submit();
	}
	//解封
	function reOpenAttendperiod() {
		var date = HRMCommon.checkY_M(document.getElementById("yearMonth"));
		if (date == null)
			return;

		if (!confirm("您确定解封" + date + "每月考勤汇总吗？"))
			return;
		document.getElementById('status').value = 0;
		document.searchAttendmonthly.action = "examin/reOpenAttendperiod.action";
		document.searchAttendmonthly.submit();
	}

	/*****************************************************
	 * 根据屏幕大小计列表框宽度
	 * 返回值： 无
	 ******************************************************/
	function resetTableWidth() {
		var width = document.body.scrollWidth - 165;
		document.getElementById('scrollDiv').style.width = width;
	}
	//页面加载后根据用户分辨率调整表格大小
	resetTableWidth();

	//点击查询
	function submitSearch() {
		var date = HRMCommon.checkY_M(document.getElementById("yearMonth"));
		if (date == null)
			return;

		document.forms[0].submit();
	}

	//数据导出
	function submitExport() {
		document.getElementById('searchOrExport').value = "export";
		document.forms[0].submit();
		document.getElementById('searchOrExport').value = "";
	}

	HRMCommon.initDialog('dlgExaminDetail');
	HRMCommon.initDialog('dlgExaminInfo');
</script>
	<jsp:include flush="true" page="../io/div_omm_select.jsp"></jsp:include>
	<jsp:include flush="true" page="../io/div_upload.jsp"></jsp:include>
</body>
